<?php

class Rcp_Methods_Request_Login {
	
	/**
	 *
	 * @var Rcp_Methods_Data_App
	 */
	public $app;
	public $email;
	public $password;
	
	public function __construct($params) {
		$this->app = new Rcp_Methods_Data_App($params->app);
		$this->email = $params->email;
		$this->password = $params->password;
	}
	
	public function process() {
		$authResult = Rcp_Auth::getInstance()
		->setLoginData(new Rcp_AuthData_Email($this->email, $this->password))
		->authenticate();
    if (!$authResult->isValid()) {
    	throw new Rcp_Exception_App(Rcp_Exception_Codes::INFO_INCORRECT_LOGIN_PARAMS);
    }
		return new Rcp_Methods_Response_Login(true);
	}
	
}